package com.bright.cwduijie.duijie.repository;

import com.bright.cwduijie.duijie.pojo.po.MonthlySettlement;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface MonthlySettlementRepository extends JpaRepository<MonthlySettlement, Integer>, JpaSpecificationExecutor<MonthlySettlement> {

    @Query("from MonthlySettlement where ZT_DATA_KEY=:ztDataKey and sjjhbz=:sjjhbz")
    List<MonthlySettlement> getByZTDATAKEYAndSjjhbz(@Param("ztDataKey") String ztDataKey, @Param("sjjhbz") int sjjhbz);

    @Query("from MonthlySettlement where ZT_DATA_KEY=:ztDataKey and KJQJ like :yearMonth%")
    List<MonthlySettlement> getByZTDATAKEYAndYearMonth(@Param("ztDataKey") String ztDataKey, @Param("yearMonth") String yearMonth);

    @Query("from MonthlySettlement where KJQJ=:yearMonth and sjjhbz=:sjjhbz")
    List<MonthlySettlement> getByYearMonthAndSjjhbz(@Param("yearMonth") String yearMonth, @Param("sjjhbz") int sjjhbz);

    @Query("select ZT_DATA_KEY from MonthlySettlement where sjjhbz = :sjjhbz group by ZT_DATA_KEY")
    List<String> getDistinctZtDataKeyBySjjhbz(@Param("sjjhbz") int sjjhbz);
}